/*
 * v1.1 by tonydon site:txdnet.cn
 * netbeansIDE 7.1
 */
package cn.txdnet.txcms.service;
import cn.txdnet.txcms.dao.AdminDAO;
import cn.txdnet.txcms.domain.Manager;
import cn.txdnet.txcms.domain.Mgrole;
import cn.txdnet.txweb.basedao.FacadeProxy;
import java.util.List;
import java.util.Map;
/**
 *
 * @author txdnet
 */
public class AdminService {
    
    /*
     *  管理员登陆操作
     */
    public static Manager loginQuery(String mgrname){
       return FacadeProxy.getAutoCommitProxy(AdminDAO.class).loginQuery(mgrname);
    }
    
    /*
     * 更新管理员参数操作
     */
    public static boolean upateBase(Map m){
        AdminDAO dao = FacadeProxy.getManualCommitProxy(AdminDAO.class);
        return ( dao.upateBase(m)>0? true:false );
    }
    
    /*
     * 删除管理员操作
     */
    public static boolean deleteAdmin(int mgrid){
        AdminDAO dao = FacadeProxy.getManualCommitProxy(AdminDAO.class);
        return ( dao.deleteAdmin(mgrid) >0? true:false );
    }
    
    /*
     * 建立管理员操作
     */
    public static boolean makeAdmin(Manager m){
        AdminDAO dao = FacadeProxy.getManualCommitProxy(AdminDAO.class);
        return ( dao.makeAdmin(m) >0? true:false );
    }
    
    /*
     * 管理员查询操作
     */
    
    public static int countByFactor(Map m){
          return FacadeProxy.getAutoCommitProxy(AdminDAO.class).countByFactor(m);
    }
    
    public static List<Map> listByFactor(Map m){
          return FacadeProxy.getAutoCommitProxy(AdminDAO.class).listByFactor(m);
    }
    
    /*
     * 查询分类管理值
     */
    public static String queryCids(int mgrid){
         return FacadeProxy.getAutoCommitProxy(AdminDAO.class).queryCids(mgrid);
    }
    
    /*
     * 查询重复管理员账号操作
     */
    public static boolean isRepeatMgrname(String mgrname){
         AdminDAO dao = FacadeProxy.getAutoCommitProxy(AdminDAO.class);
         return ( dao.queryRepeatMgrname(mgrname)>0?true:false );
    }
    
    /*
     * 查询管理员角色级别
     */
    public static int queryRoleId(int mgrid){
         return FacadeProxy.getAutoCommitProxy(AdminDAO.class).queryRoleId(mgrid);
    }
    
    
    
    /*********************
     * 建立管理员角色操作
     */
    public static boolean makeRole(Mgrole r){
        AdminDAO dao = FacadeProxy.getManualCommitProxy(AdminDAO.class);
        return ( dao.makeRole(r)>0 ? true:false );
    }
    
    /*
     * 更新角色操作
     */
    public static boolean updateRole(Mgrole r){
        AdminDAO dao = FacadeProxy.getManualCommitProxy(AdminDAO.class);
        return ( dao.updateRole(r) >0 ? true:false );
    }
    
    /*
     * 删除角色操作
     */
    public static boolean deleteRole(int roleid){
        AdminDAO dao = FacadeProxy.getManualCommitProxy(AdminDAO.class);
        return  ( dao.deleteRole(roleid) >0 ? true:false );
    }
    
    
    /*
     * 列出角色操作
     */
    public static List<Mgrole> listRole(){
         return FacadeProxy.getAutoCommitProxy(AdminDAO.class).listRole();
    }
    
    /*
     * 列出角色用于select 选框
     */
    public static List<Map> listRoleBase(){
         return FacadeProxy.getAutoCommitProxy(AdminDAO.class).listRoleBase();
    }
    
    /*
     * 查询角色详情操作
     */
    public static Mgrole queryRole(int roleid){
       return FacadeProxy.getAutoCommitProxy(AdminDAO.class).queryRole(roleid);
    }
    
    /*
     *  查询角色总数
     */
    public static int countRole(){
        return FacadeProxy.getAutoCommitProxy(AdminDAO.class).countRole();
    }
    
}
